home *** CD-ROM | disk | FTP | other *** search
- /* -*-c-*- */
-
- /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
-
- This file is part of GNU CC.
-
- GNU CC is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU CC is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
- /*
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/include/RCS/objc-proto.h,v 0.13 1992/04/13 11:40:53 dennisg Exp dennisg $
- $Author: dennisg $
- $Date: 1992/04/13 11:40:53 $
- $Log: objc-proto.h,v $
- * Revision 0.13 1992/04/13 11:40:53 dennisg
- * Check in after array version of run-time works.
- * Expect more changes as hash version and other changes are made.
- *
- * Revision 0.12 1992/01/03 02:57:08 dennisg
- * modified to handle new initialization scheme.
- * fixed code structure.
- *
- * Revision 0.11 1991/12/10 12:03:22 dennisg
- * Cleaned up file format for a distribution.
- * Added a prototype for archiving. Now all I have to do is write it.
- *
- * Revision 0.10 1991/12/07 00:57:20 dennisg
- * added objc_classSize() prototype.
- *
- * Revision 0.9 1991/12/06 00:36:24 dennisg
- * added type decls for objc_msgSend*().
- *
- * Revision 0.8 1991/12/01 01:29:29 dennisg
- * modified to remove changes previously made to
- * implement posing. posing just got easy.
- *
- * Revision 0.7 1991/11/29 22:00:10 dennisg
- * modified to implement set functions.
- *
- * Revision 0.6 1991/11/29 20:02:01 dennisg
- * fixed several const decls. bozo.
- *
- * Revision 0.5 1991/11/29 13:32:16 dennisg
- * committed some functions to inline and changes prototypes
- * to match.
- * also added some documentation.
- *
- * Revision 0.4 1991/11/29 00:24:14 dennisg
- * many changes including posing, things to make the compiler
- * happier, structure changes, and things to make it play better.
- *
- * Revision 0.3 1991/11/16 16:26:02 dennisg
- * changed some prototypes to make
- * the compiler happier.
- *
- * Revision 0.2 1991/11/07 22:31:42 dennisg
- * added copyleft.
- *
- * Revision 0.1 1991/10/24 00:19:24 dennisg
- * Initial check in. Preliminary development stage.
- *
- */
-
-
- #ifndef _objc_proto_INCLUDE_GNU
- #define _objc_proto_INCLUDE_GNU
-
- #include <objc.h>
- #include <objc-protoP.h>
-
- #include <stdlib.h>
-
-
- /*
- * Compiler defined prototypes.
- * These prototypes can't be defined if we're
- * compiling Objective-C code.
- */
- #ifndef __OBJC__
- /*
- * objc_getClass() returns the id of the class
- * object for the aClassName class. The class
- * object holds information used by instances of
- * the class.
- *
- * Print a message to the standard error stream if
- * aClassName isn't part of the executable image.
- */
- Class_t
- objc_getClass (const char*);
-
- /*
- * objc_getMetaClass() returns the id of the
- * meta class object for the aClassName class.
- * The meta class object holds information used
- * by the class object, just as the class
- * object holds information used by instances
- * of the class.
- *
- * Print a message to the standard error stream
- * if aClassName isn't part of the executable image.
- */
- MetaClass_t
- objc_getMetaClass (const char*);
-
- /*
- * The compiler converts every message expression into a
- * call on one of these two functions. Messages to
- * super are converted to calls on objc_msgSendSuper();
- * all others are converted to calls on objc_msgSend().
- *
- * These functions return the address of the method
- * implementation. The compiler then generates calls
- * to those methods passing the full argument array.
- *
- * Calls to objc_msgSend() and objc_msgSendSuper()
- * should be generated only by the compiler. You shouldn't
- * call them directly in the Objective-C code you write.
- */
- IMP
- objc_msgSend (id, SEL);
-
- IMP
- objc_msgSendSuper (Super_t, SEL);
- #endif
-
- /*
- * Given the name of a variable within a class's
- * definition, return a pointer to a structure that
- * describes it.
- */
- Ivar_t
- object_getIvarAddress (id aObject, const char* variableName);
-
- /*
- * Given a class and a selector, return a pointer to the method's method
- * structure. Return NULL if not found.
- *
- * This is a method internal to the run-time.
- */
- Method_t
- searchForMethodInHierarchy (Class_t, SEL);
-
-
- /*
- * class_getInstanceMethod() returns a pointer
- * to the data structure that describes the method.
- *
- * The selector must identify an
- * instance method.
- *
- * Return a NULL pointer if aSelector doesn't
- * identify a method defined in or inherited
- * by aClass.
- */
- static inline Method_t
- class_getInstanceMethod (Class_t aClass, SEL aSel) {
-
- return searchForMethodInHierarchy (aClass, aSel);
- }
-
- /*
- * class_getClassMethod() returns a pointer to
- * the data structure that describes the method.
- *
- * The selector must identify a class (factory) method.
- *
- * Return a NULL pointer if aSelector doesn't
- * identify a method defined in or inherited by aClass.
- */
- static inline Method_t
- class_getClassMethod (MetaClass_t aClass, SEL aSel) {
-
- return searchForMethodInHierarchy ((Class_t)aClass, aSel);
- }
-
- /*
- * This function returns the name of aObject's
- * class. anObject should be an instance
- * object, not a class object.
- */
- static inline const char*
- object_getClassName (id aObject) {
-
- return aObject->isa->name;
- }
-
- /*
- * This function returns the name of the
- * class.
- */
- static inline const char*
- class_getClassName (Class_t aClassObject) {
-
- return aClassObject->name;
- }
-
- /*
- * The first function, sel_getUid(), returns a selector that's
- * used at run time to identify the aName method. Whenever
- * possible, you should use the @selector() directive to
- * ask the compiler, rather than the run-time system,
- * to provide the selector for a method. This function
- * should be used only if the name isn't known at compile
- * time.
- *
- * The second function, sel_getName(), is the inverse
- * of the first. It returns the name that was mapped to
- * aSelector.
- */
- SEL
- sel_getUid (const STR);
-
- const STR
- sel_getName (SEL);
-
- /*
- * class_addInstanceMethods() adds methods that can be
- * used by instances of the class and class_addClassMethods()
- * adds methods used by the class object. Before adding a
- * method, both functions check for duplicates. A warning
- * is sent to the standard error stream if any ambiguities exist.
- *
- * The passed structure and its contents must exist for the the
- * duration of the program. These functions don't support
- * linked structures.
- */
- static inline void
- class_addInstanceMethods (Class_t aClass, MethodList_t aMethodList) {
-
- addMethodsToClass (aClass, aMethodList);
- }
-
- static inline void
- class_addClassMethods (Class_t aClass, MethodList_t aMethodList) {
-
- addMethodsToClass ((Class_t)aClass->isa, aMethodList);
- }
-
- /*
- * This function returns the number of bytes that all of aMethod's
- * arguments, taken together, would occupy on the stack.
- */
- static inline u_int
- method_getSizeOfArguments (Method_t aMethod) {
-
- return atoi (&aMethod->method_types[1]);
- }
-
- /*
- * This function returns the size in bytes of a
- * instance of aObject.
- */
- static inline long
- objc_classSize (id aObject) {
-
- return aObject->isa->instance_size;
- }
-
- /*
- * This function returns the number of arguments that aMethod
- * the takes. This will be at least two, since it
- * includes the “hidden” arguments, self and _cmd,
- * which are the first two arguments passed to every
- * method implementation.
- */
- u_int
- method_getNumberOfArguments (Method_t aMethod);
-
- /* This functiontakes an index into aMethod's argument
- * list and returns, by reference, the type of the argument
- * and the offset to the location of that argument in the
- * list. Indices begin with 0. The “hidden” arguments
- * self and _cmd are indexed at 0 and 1; method-specific
- * arguments begin at index 2. The offset is measured in
- * bytes and depends on the size of arguments preceding the
- * indexed argument in the argument list. The type is
- * encoded according to the conventions of the @encode()
- * compiler directive.
- */
- u_int
- method_getArgumentInfo (Method_t aMethod,
- int indx, const char **type, int *offset);
-
- /*
- * This function is used to support archiving when a unknown class is to read
- * from a archive. This function returns a instantiated object. To further
- * dearchive the object it should be sent: -readFrom:.
- *
- * This function positions the file pointer just past class Object's class
- * data.
- */
- id
- objc_objectFromFile (int aFd);
-
-
- /* Some functions that I've been told are useful by Henry Flurry */
-
- /* Returns a C string representing the ASCII rep of the selector. */
- static inline const char*
- SELNAME(SEL sel) {
-
-
- return sel_getName (sel);
- }
-
- /*
- * Converts a C string to a SEL that can be used in perform: methods,
- * objc_msgSend(), etc.
- */
- static inline SEL
- SELUID(const STR str) {
-
- return sel_getUid (str);
- }
-
- /*
- * Returns the class name of the object (or meta class name of a class
- * object), or some _nilName if obj is nil.
- */
- static inline const char*
- NAMEOF(id obj) {
-
- const char* theName = NULL;
-
-
- if (obj)
- if (obj->isa->info & CLS_CLASS)
- theName = object_getClassName (obj);
- else
- if (((Class_t)obj)->isa->info & CLS_META)
- theName = class_getClassName ((Class_t)obj);
-
- return theName;
- }
-
-
- #endif
-
-